/* ---------------------------------------------------------------------------
   (c) Copyright 2006 ActivIdentity, Inc.
   All Rights Reserved.

   This program is an unpublished copyrighted work which is proprietary
   to ActivIdentity. This computer program includes Confidential,
   Proprietary Information and is a Trade Secret of ActivIdentity.
   Any use, disclosure, modification and/or reproduction is prohibited
   unless authorized in writing by ActivIdentity.

   WARNING:  Unauthorized reproduction of this program as well as
   unauthorized preparation of derivative works based upon the
   program or distribution of copies by sale, rental, lease or
   lending are violations of federal copyright laws and state trade
   secret laws, punishable by civil and criminal penalties.
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Disclaimer

   ACTIVIDENTITY MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE 
   CONTENTS OR USE OF THIS SOFTWARE, AND SPECIFICALLY DISCLAIMS ANY EXPRESS
   OR IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
   PURPOSE. Further, ActivIdentity reserves the right to revise this software
   and to make changes to its content, at any time, without obligation to
   notify any person or entity of such revisions or changes.
   --------------------------------------------------------------------------- */

#ifndef __ACPCAPI_H__
#define __ACPCAPI_H__

#ifdef __cplusplus
extern "C" {
#endif

#if defined(WIN32)
/* Windows standard files and definitions */
#include <windows.h>
#else
/* Unix standard files and definitions */
#include <stdio.h>
#define CALLBACK
#endif

/***************/
/** CONSTANTS **/
/***************/
#define IN
#define INOUT
#define OUT

/* Accessors to retrieve the various parts of the version */
#define ACPC_MAJOR_VERSION(x)		ACM_MAJOR_VERSION(x)
#define ACPC_MINOR_VERSION(x)		ACM_MINOR_VERSION(x)
#define ACPC_BUILD_VERSION(x)		ACM_BUILD_VERSION(x)

#define ACPC_VERSION_VERSIONLEN		ACM_VERS_VERSIONLEN
#define ACPC_VERSION_COPYRIGHTLEN	ACM_VERS_COPYRIGHTLEN
#define ACPC_VERSION_COMMENTLEN		ACM_VERS_COMMENTLEN

/**********************/
/** TYPE DEFINITIONS **/
/**********************/

/* Error definitions*/
typedef enum {
    ACPC_API_ERROR = -1,
    ACPC_MEMORY_ERROR = -2,
    ACPC_UNKNOWN_ERROR = -3,
    ACPC_BAD_PARAM_ERROR = -4,
    ACPC_FILE_ERROR = -5,
    ACPC_INVALID_HANDLE_ERROR = -6,
    ACPC_INVALID_CONTEXT_ERROR = -7,
    ACPC_NULL_PARAM_ERROR = -8,
    ACPC_INVALID_BUFFER_ERROR = -9,
    ACPC_ENUMERATE_END = -10,
    ACPC_SIGNATURE_VERIFIED = -11,
    ACPC_SIGNATURE_NOT_VERIFIED = -12,
    /* API Errors */
    ACPC_OK = 0,
    ACPC_SDB_GENERATION_ERROR = 1,
    ACPC_TYPECHECK_ERROR = 2,
    ACPC_TREECHECK_ERROR = 3,
    ACPC_ENTRYCHECK_ERROR = 4,
    ACPC_LOADCONFIG_ERROR = 5,
    ACPC_CALLAGENT_ERROR = 6,
    ACPC_NOTFOUND_ERROR = 7,
    ACPC_PARSE_ERROR = 8,
    ACPC_SYNTAX_ERROR = 9,
    ACPC_PUSH_ERROR = 10,
    ACPC_NOSIGN_ERROR = 11,
    ACPC_INVALID_EXPORT_ATTRIBUTE_ERROR = 12,
    ACPC_AGENT_NOT_IMPLEMENTED_ERROR    = 13
} ACPCErrors;

typedef enum {
    ACPC_LDIF_PROFILE_FORMAT = 0,
    ACPC_SIMPLE_PROFILE_FORMAT = 1
} ACPCProfileFormat;

typedef enum {
    ACPC_API = 0
} ACPCModuleId;

typedef enum {
    ACPC_IMAGE_NAME = 0,
    ACPC_IMAGE_TARGET = 1,
    ACPC_PC_VERSION = 2
} ACPCImageInfos;

typedef enum {
    ACPC_DEVICE_TARGET = 1,
    ACPC_BACKEND_TARGET = 2
} ACPCImageTarget;

typedef void *ACPCKBHandle;
typedef void *ACPCProfileHandle;
typedef void *ACPCObjectLocation;

/***************/
/** FUNCTIONS **/
/***************/
int CALLBACK acPCOpenKB(
		IN const char *pszKBdefinitions,
		IN const char *pszKBdeclarations,
		IN const char *pszKBuserdata,
		OUT ACPCKBHandle *pKBHandle);

int CALLBACK acPCCloseKB(
		IN ACPCKBHandle KBHandle);

int CALLBACK acPCOpenProfile(
		IN const ACPCKBHandle KBHandle,
		IN const char *pszProfileBuffer,
		IN ACPCProfileFormat Format,
		OUT ACPCProfileHandle  *pProfileHandle);

int CALLBACK acPCCloseProfile(
		IN ACPCProfileHandle ProfileHandle);

int CALLBACK acPCSignProfile(
		IN ACPCProfileHandle ProfileHandle,
		IN const char *pszSignParameters);

int CALLBACK acPCVerifyProfile(
		IN ACPCProfileHandle   ProfileHandle,
		IN const char *pszVerifyParameters);

int CALLBACK acPCExportProfile(
		IN ACPCProfileHandle ProfileHandle,
		OUT char **ppszOutProfileBuffer,
		IN ACPCProfileFormat Format);

int CALLBACK acPCGetProfileAttribute(
		IN ACPCProfileHandle ProfileHandle,
		IN const char *pszServiceName,
		IN const char *pszAttributeName,
		OUT char **ppszValue);

int CALLBACK acPCSetProfileAttribute(
		IN ACPCProfileHandle ProfileHandle,
		IN const char *pszServiceName,
		IN const char *pszAtributeName,
		IN const char *pszValue);

int CALLBACK acPCGenerateImage(
		IN ACPCProfileHandle ProfileHandle,
		IN const char *pszRuntimeParameters,
		IN unsigned long ulProcessFlag, 
		IN const char *pszServiceList,
		IN const char *pszKey,
		IN unsigned int ulCryptoMethod,
		OUT SDB **ppOutSDBarray,
		OUT int *pnNbSDB);

int CALLBACK acPCGetImageInfo(
		IN char *pszKey,
		IN const SDB *pSDBimage, 
		IN int nWhat, 
		OUT char **ppszInfo);

int CALLBACK acPCFreeImage(
		IN SDB *pSDBarray,
		IN int nNbSDB);

int CALLBACK acPCGetNbErrors(
		IN void *ProfileOrKBHandle,
		OUT int *pnNbErrors);

int CALLBACK acPCGetError(
		IN void *ProfileOrKBHandle,
		IN int nErrorId,
		OUT char **ppszErrorString,
		OUT int  *pnErrorCode,
		OUT ACPCObjectLocation *pLocation);

int CALLBACK acPCFreeBuffer(
		IN const char *pszBuffer);

int CALLBACK acPCGetVersion(
		OUT char *pszVersion,
		OUT unsigned long *plVersion,
		OUT char *pszCopyright,
		OUT char *pszComment);

#ifdef __cplusplus
    }
#endif

#endif /* __ACPCAPI_H__ */
